package com.huaxinkai.service;


import java.util.List;
import java.util.Map;

import org.hibernate.Session;

import com.huaxinkai.entity.BaseEntity;

/**
 * baseDao dao接口
 * @author liuzh
 * @date 2017年5月11日
 */
@SuppressWarnings({"rawtypes"})
public interface IBaseDao {
	/**
	 * 获取session
	 * @return session
	 * @throws Exception
	 */
	public Session getSession() throws Exception;

	public void begin() throws Exception;

	public void commit() throws Exception;
	

	/**
	 * 获得在当前Thread中的session
	 * 
	 * @throws Exception
	 */
	public void getCurrentSession() throws Exception;

	/**
	 * 开启session
	 * 
	 * @throws Exception
	 */
	public void openSession() throws Exception;

	/**
	 * 关闭session
	 * 
	 * @throws Exception
	 */
	public void closeSession() throws Exception;

	/**
	 * 增加实体
	 * 
	 * @param entity
	 *          实体
	 * @return 添加是否成功
	 * @throws Exception
	 */
	public boolean insert(BaseEntity entity) throws Exception;

	public boolean delete(BaseEntity entity) throws Exception ;

	public boolean update(BaseEntity entity) throws Exception ;

	public Object selectOne(String sql) throws Exception ;

	public Object selectOne(Class clazz, int id) throws Exception ;

	public Object selectOne(Class clazz, String column, Object value) throws Exception ;

	public List query(Class clazz, String column, Object value) throws Exception ;

	public List query(Class clazz, String[] column, Object[] value) throws Exception ;
	
	public Object selectOne(String hql, Map<String, Object> params) throws Exception ;

	public List select(String hql) throws Exception ;

	public List select(Class clazz) throws Exception ;

	public List select(Class clazz, Integer... ids) throws Exception ;

	public List select(Class clazz, int page, int rows) throws Exception;

	public List select(String hql, Map<String, Object> params) throws Exception ;
	
	public List select(String hql, Map<String, Object> params, int page, int rows) throws Exception ;

	public long selectCount(Class clazz) throws Exception ;

	public long selectCount(String hql, Map<String, Object> params) throws Exception;


	public boolean delete(List<BaseEntity> entities) throws Exception ;

	public boolean insert(List<BaseEntity> entities) throws Exception ;

}
